﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HtmlAgilityPack;
using System.Drawing;

namespace FreeIMDB
{
    class MovieRepository : IMovieRepository
    {
        private readonly MovieDownloader _downloader;
        private HtmlDocument _page;
        
        /// <summary>
        /// Returns a populated Movie object full of scraped, relevant information.
        /// </summary>
        /// <param name="id">IMDB movie id.</param>
        /// <returns>Returns a populated Movie object.</returns>
        public Movie FindMovieById(string id)
        {            
            _page = _downloader.ByID(id);
            Movie movie = PopulateMovie();
            return movie;
        }

        /// <summary>
        /// Returns a populated Movie object full of scraped, relevant information.
        /// </summary>
        /// <param name="title">IMDB movie title.</param>
        /// <returns>Returns a populated Movie object.</returns>
        public Movie FindMovieByTitle(string title)
        {
            _page = _downloader.ByName(title);
            Movie movie = PopulateMovie();
            return movie;
        }

        #region "Movie Field Populating"
        private Movie PopulateMovie()
        {
            Movie movie = new Movie();
           
            movie.Poster = Poster();
            movie.Title = Title();
            movie.ReleaseDate = ReleaseDate();
            movie.Rating = Rating();
            movie.Director = Director();
            movie.Writers = Writers();
            movie.Genres = Genres();
            movie.Tagline = Tagline();
            movie.Plot = Plot();
            movie.Cast = Cast();
            movie.Runtime = Runtime();
            movie.Country = Country();
            movie.Language = Language();

            return movie;
        }
        #endregion

        #region "Individual Scraping" //All of these will be implemented later on using HTMLAgilityPack.
        private Image Poster()
        { 
        }

        private string Title()
        { 
        }

        private DateTime ReleaseDate()
        { 
        }

        private string Rating()
        { 
        }

        private string Director()
        { 
        }

        private List<string> Writers()
        { 
        }

        private List<string> Genres()
        { 
        }

        private string Tagline()
        { 
        }

        private string Plot()
        { 
        }

        private List<string> Cast()
        { 
        }

        private string Runtime()
        { 
        }

        private string Country()
        {
        }

        private string Language()
        { 
        }
        #endregion
    }
}

